<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class AdminRegisterRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            //定义规则
            'username' => 'required|regex:[^\w{4,15}$]',
            'userpassword' => 'required',
            'repassword' =>'required|same:userpassword',
            'useremail'=> 'required|email',
            'useraudit'=> 'required',
            'userlevel'=> 'required',
            'userremark'=> 'required'
        ];
    }
    public function messages()
    {
        return[
        // 定义错误显示
            'username.required'=>'用户名不能为空',
            'username.regex'=>'用户名格式不正确,为6-15位字母数字下划线',
            'userpassword.required'=>'密码不能为空',
            'repassword.required'=>'确认密码不能为空',
            'useremail.required'=>'用户邮箱不能为空',
            'useremail.email'=>'邮箱格式不正确',
            'repassword.same'=>'两次密码不一致',
            'useraudit.required'=>'用户审核不能为空',
            'userlevel.required'=>'用户权限不能为空',
            'userremark.required'=>'用户备注不能为空'
        ];
    }





}
